DECLARE @version smallint;
DECLARE @reqVersion smallint;

--Set required version number here 
SET @reqVersion = 2;

SELECT @version = VersionNumber
FROM SchemaVersion 
WHERE IsCurrent = 1;

IF (@version = @reqVersion)
BEGIN
--Update logic goes here


	
--Updating version
	
INSERT INTO SchemaVersion(VersionNumber, IsCurrent) VALUES(@version + 1, 1);
UPDATE SchemaVersion SET IsCurrent = 0 WHERE VersionNumber = @version;
END ELSE
BEGIN
	print('ERROR! Incorrect version, please check updates for version' + CONVERT(varchar(10),@version));
END;	